<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="stylesheet" href="__CSS__/layui.css">
    <link rel="stylesheet" href="__CSS__/view.css"/>
    <title></title>
</head>
<body class="layui-view-body">
    <div class="layui-content">
        <div class="layui-row">
            <div class="layui-card">
                <div class="layui-card-header">修改信息</div>
                <form class="layui-form layui-card-body" name="form" action="" method="post">
                <input type="hidden" name="agid" value="{$date['agent_id']}">
                  <div class="layui-form-item">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-block">
                      <input type="text" disabled="disabled" value="{$date['agent_account']}" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-block">
                      <input type="text" name="name" required lay-verify="required"  value="{$date['agent_name']}" placeholder="请输入姓名" autocomplete="off" class="layui-input">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">手机号</label>
                    <div class="layui-input-block">
                      <input type="number" name="phone" id="phone" required lay-verify="required" value="{$date['agent_phone']}" placeholder="请输入手机号" autocomplete="off" class="layui-input">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">身份证</label>
                    <div class="layui-input-block">
                      <input type="text" name="idcard" id="idcard" required lay-verify="required" value="{$date['agent_idcard']}" placeholder="请输入身份证" autocomplete="off" class="layui-input">
                    </div>
                  </div>

                  {if $AGENT_GRADE == 1}
                  <div class="layui-form-item">
                    <label class="layui-form-label">选择修改的代理等级</label>
                    <div class="layui-input-block">
                      <select name="grade_id" lay-verify="required">
                        <option value=""></option>
                          {volist name="list" id="va"}
                          <option value="{$va.grade_id}" {$date['agent_grade']==$va.grade_id?selected:''}>{$va.grade_name}</option>
                          {/volist}
                      </select>
                    </div>
                  </div>
                  {else}
                  <div class="layui-form-item">
                    <label class="layui-form-label">客户容纳人数</label>
                    <div class="layui-input-block">
                      <input type="radio" name="types" value="add" title="增加" checked="true">
                      <input type="radio" name="types" value="del" title="减少">
                      <input type="number" name="capacity" required lay-verify="required" min="0" value="{$date['agent_can_allot']}" placeholder="请输入增加或减少的容纳数量" autocomplete="off" class="layui-input">
                      <span>123</span>
                      <!-- <span class="layui-btn">减少</span> -->
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">还款费率‰</label>
                    <div class="layui-input-block">
                      <input type="number" name="hk" required lay-verify="required" min="0" step="0.01" value="{$date['fl']['1']}" placeholder="请输入签署费率" autocomplete="off" class="layui-input">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">收款费率‰</label>
                    <div class="layui-input-block">
                      <input type="number" name="sk" required lay-verify="required" min="0" step="0.01" value="{$date['fl']['2']}" placeholder="请输入签署费率" autocomplete="off" class="layui-input">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">升级费率‰</label>
                    <div class="layui-input-block">
                      <input type="number" name="sj" required lay-verify="required" min="0" step="0.01" value="{$date['fl']['3']}" placeholder="代理升级费率" autocomplete="off" class="layui-input">
                    </div>
                  </div>
                  {/if}
                  <div class="layui-form-item">
                    <div class="layui-input-block">
                      <span class="layui-btn layui-btn-blue" lay-submit lay-filter="formDemo" onclick="sub()">立即提交</span>
                    </div>
                  </div>
                </form>  
            </div>
        </div>
    </div>
    <script src="__JS__/layui.all.js"></script>
    <script src="__JS__/layer/layer.js"></script>
    <script src="__JS__/jquery.min.js"></script>
    <script>
      var form = layui.form
        ,layer = layui.layer;
    </script>
</body>
<script>
  function sub(){
    var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
    if(myreg.test($("#phone").val())=== false){
      layer.msg('请输入正确的手机号');
      return false;
    }
    var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
    if(reg.test($("#idcard").val()) === false){
      layer.msg('请输入正确的身份证');
      return false;
    }
    $.post("{:Url('agent/user/upagent')}",$("form").serialize(),function(data){
      if(data.error==0){
        layer.msg(data.msg,{time:2000},function(){
          var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
          parent.layer.close(index); //再执行关闭
        })
      }else{
        layer.msg(data.msg);
      }
    })
  }
</script>
</html>